﻿

Public Class HotNewsControl
    Inherits System.Web.UI.UserControl

    Protected dsSource As DataSet

    Public Property DataSource() As DataSet
        Get
            Return dsSource
        End Get
        Set(value As DataSet)
            dsSource = value
        End Set
    End Property

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        dsSource = Me.GetHotNews()
    End Sub

    Private Function GetHotNews() As DataSet

        Dim xSql As String
        Dim ds As DataSet
        Dim dataAccess As DBAccess

        Try
            dataAccess = New DBAccess(ConfigurationManager.ConnectionStrings("ConStr").ConnectionString)

            xSql = ""
            xSql = xSql & vbCrLf & "SELECT TOP 5"
            xSql = xSql & vbCrLf & "		T_NEWS.CODE,"
            xSql = xSql & vbCrLf & "		T_NEWS.NAME        AS TITLE,"
            xSql = xSql & vbCrLf & "		T_NEWS.LINK_NAME,"
            xSql = xSql & vbCrLf & "		T_NEWS.IMG_LINK,"
            xSql = xSql & vbCrLf & "		T_NEWS.SUMMARY,"
            xSql = xSql & vbCrLf & "		T_NEWS.CONTENT,"
            xSql = xSql & vbCrLf & "		T_NEWS.TAG,"
            xSql = xSql & vbCrLf & "		T_NEWS.DEL_FLG,"
            xSql = xSql & vbCrLf & "		T_NEWS.AD_DATE,"
            xSql = xSql & vbCrLf & "		T_NEWS.UD_DATE"
            xSql = xSql & vbCrLf & "FROM "
            xSql = xSql & vbCrLf & "        T_NEWS"
            xSql = xSql & vbCrLf & "WHERE"
            xSql = xSql & vbCrLf & "        T_NEWS.DEL_FLG = 0"
            xSql = xSql & vbCrLf & "ORDER BY"
            xSql = xSql & vbCrLf & "        T_NEWS.UD_DATE DESC"

            ds = dataAccess.GetDBDataset(xSql)

            Return ds
        Catch ex As Exception
            Throw ex
        End Try
    End Function
End Class